/**
 * File: BatchSequenceWriteProcessor.java
 * Created by: mhaimel
 * Created on: 27 Jul 2009
 * CVS:  $Id: BatchSequenceWriteProcessor.java,v 1.2 2009/10/09 15:14:58 mhaimel Exp $
 */
package uk.ac.ebi.curtain.processor.writer.impl;

import org.apache.commons.lang.NotImplementedException;

import uk.ac.ebi.curtain.controller.loader.impl.ReadsWriteBean;
import uk.ac.ebi.curtain.controller.velvet.VelvetInputBean;
import uk.ac.ebi.curtain.processor.AbstractQueueProcessor;

/**
 * @author mhaimel
 *
 */
public class BatchSequenceWriteProcessor extends AbstractQueueProcessor<ReadsWriteBean, VelvetInputBean> {
	
	@Override
	public void process() {
		int cnt = 0;
		SequenceWriteProcessor writer = getContext().getInjector().getInstance(SequenceWriteProcessor.class);
		getLog().debug("Run Batch Sequence writer from queue ");
		try {
			while(true){
				if(isForceShutdown()){
					break;
				}
				ReadsWriteBean in = null;
				in = takeInput();
				if(null != in){
					++cnt;
					writer.reset();
					writer.setInput(in);
					writer.process();
					VelvetInputBean out = writer.buildReturnObject();
					submitOutput(out);
				} else if(getInputQueue().isShutdown()){
					break;
				}
			}
		} catch (InterruptedException e) {
			getLog().warn("Interupted!!!",e);
			Thread.currentThread().interrupt();
		}
		getLog().info("Finished with processed items: " + cnt);
	}


	@Override
	protected VelvetInputBean buildReturnObject() {
		return null;
	}

	@Override
	protected VelvetInputBean doProcess(ReadsWriteBean input) {
		throw new NotImplementedException();
	}
}
